//
//  ScenarioBuilder.m
//  iD20
//
//  Created by Andrew Spina on 5/18/10.
//  Copyright 2010 STScI. All rights reserved.
//

#import "ScenarioBuilder.h"


@implementation ScenarioBuilder

@synthesize mapPicker;
@synthesize mapImage;
@synthesize mapGrid;
@synthesize viewToZoom;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	[self beginBuildingSequence];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
	return viewToZoom;
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
	UIImage * img = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
//	UIImage * img = (UIImage *) [info valueForKey:UIImagePickerControllerEditedImage];
	mapImage.image = img;
	CGRect newFrame = CGRectMake((float)0.0, (float)0.0, img.size.width, img.size.height);
	NSLog(@"Picked Map Image: %@", img);
	mapImage.frame = newFrame;
	mapGrid.frame = newFrame;
	//mapGrid.backgroundColor = [UIColor redColor];
//	NSLog(@"ImageFrame: %@ GridFrame: %@", mapImage.frame, mapGrid.frame);
	[picker dismissModalViewControllerAnimated:NO];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
	NSLog(@"Should Cancel Image Picking");
	[picker dismissModalViewControllerAnimated:NO];
}


- (void)dealloc {
    [super dealloc];
}
	
- (void) beginBuildingSequence {
	NSLog(@"Begin Scenario Building Sequence");
	[self presentModalViewController:mapPicker animated:NO];
}


@end
